﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;

public class TestData : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        //A a = new A();
        //string s = DataEncryption.ConductEncryption(JsonUtility.ToJson(a));
        //Debug.Log(s);
        //s = DataEncryption.ConductDecrypt(s);
        //File.WriteAllText(Application.dataPath + "/a.data", s);
        //A aa = JsonUtility.FromJson<A>(s);
        //Debug.Log(aa.a);
        //string s = File.ReadAllText(Application.dataPath + "/a.json");
        //using (FileStream fs = new FileStream(Application.dataPath + "/a.data", FileMode.Open))
        //{
        //    byte[] data = new byte[fs.Length];
        //    if (data.Length == 0)
        //        return;
        //    fs.Read(data, 0, data.Length);
        //    byte[] bomBuffer = new byte[] { 0xef, 0xbb, 0xbf };
        //    string dataStr = System.Text.Encoding.UTF8.GetString(data);
        //    if (data[0] == bomBuffer[0]
        //        && data[1] == bomBuffer[1]
        //        && data[2] == bomBuffer[2])
        //    {
        //        int copyLength = data.Length - 3;
        //        byte[] dataNew = new byte[copyLength];
        //        Buffer.BlockCopy(data, 3, dataNew, 0, copyLength);
        //        dataStr = System.Text.Encoding.UTF8.GetString(dataNew);
        //    }
        //    //s = Encoding.UTF8.GetString(data);
        //    string s = DataEncryption.ConductDecrypt(dataStr);
        //    A aa = JsonUtility.FromJson<A>(s);
        //    Debug.Log(aa.a);
        //}

    }

    // Update is called once per frame
    void Update()
    {
        
    }
    [Serializable]
    public class A
    {
        public string a = "123";
        public int b = 1;
    }
}

